import java.io.*;
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import myutil.*;

public class chumma extends JFrame implements ActionListener
{
    public static JPanel     jp1, jp;
    public static JButton    jb;
    public static JTextField name_1;
    public static JTextField name_2;
    public static JLabel     jl;
    public static JLabel     Output,just;
    public static Font       f,f1;
    public static StringBuffer name1, name2;

    public chumma()
    {

	this.setVisible(true);
	this.setSize(300, 200);
	this.setLocation(400,300);
	
	this.setTitle("The Simple Love Calculator");
	f = new Font("serif", 2, 14);
	f1=new Font("sansserif",Font.BOLD,18);
	addWindowListener(new MyWindowAdapter(this));
	jp = new JPanel(new GridLayout(6, 2));
	jp1 = new JPanel(new GridLayout(1, 1));
	jb = new JButton("Check It");
	jb.setFont(f);
	jl = new JLabel("         FLAMES ");
	just=new JLabel("     The Relatioship is  ");
	just.setVisible(false);
	name_1 = new JTextField();
	name_1.setFont(f);
	name_2 = new JTextField();
	name_2.setFont(f);
	Output = new JLabel(" ");
	Output.setFont(f1);
	jp.add(jl);
	jp.add(new JLabel("Funny Reationship Finder"));
	jp.add((new JLabel("Enter the NAme1")));
	jp.add(name_1);
	jp.add((new JLabel("Enter the NAme2")));
	jp.add(name_2);
	jp.add(new JLabel("                  "));
	jp.add(jb);
	jp.add(just);
	jp.add(Output);
	// jp.add();

	add(jp);
	jb.addActionListener(this);
    }

    public void actionPerformed(ActionEvent ae)
    {

	FLAMES();
    }

    public void FLAMES()
    {

	name1 = new StringBuffer(name_1.getText());
	name2 = new StringBuffer(name_2.getText());
	for (int i = 0; i < name1.length(); i++)
	{
	    char ch = name1.charAt(i);
	    for (int j = 0; j < name2.length(); j++)
	    {
		if (ch == name2.charAt(j))
		{
		   
		    name1.deleteCharAt(i);
		    name2.deleteCharAt(j);
		    i = -1;
		    break;
		}

	    }

	}
	

	int totallength = name1.length() + name2.length();
	

	StringBuffer str = new StringBuffer("FLAMES");
	int cancel_value = 1;

	for (int i = 0; i < 5; i++)
	{
	    cancel_value = totallength % str.length();

	    if (cancel_value == 0)
	    {
		cancel_value = str.length();
	    }
	    cancel_value--;

	    if (cancel_value == 0)
	    {

		str = new StringBuffer(str.substring(1));
	    } else if (cancel_value == (str.length() - 1))
	    {

		str = new StringBuffer(str.substring(0, str.length() - 1));
	    } else
		str = new StringBuffer(str.substring(cancel_value + 1)
			+ str.substring(0, cancel_value));

	}

	just.setVisible(true);
	Output.setText(relation(str.charAt(0)));
	

    }
public static void main(String a[])
{
  chumma aa=new chumma();  
}
public String relation(char ch)
{
    String str1="";
    switch(ch)
    {
	case 'F':
	str1= "FRIENDS";
	break;
	case 'L':
		str1="LOVERS";
		break;
	case 'A':
		str1= "AFFECTION";
		break;
	case 'M':
		str1="MARRIAGE";
		break;
	case 'E':
		str1="ENEMY";
		break;
	case 'S':
	str1="SISTER";
	break;
		
    }
    return str1;
    
}
  }

class MyWindowAdapter extends WindowAdapter 
{
    chumma sampleFrame;
    
    public MyWindowAdapter(chumma sampleFrame) 
    {
	this.sampleFrame = sampleFrame;
    }
    
    public void windowClosing(WindowEvent we) 
    {
	sampleFrame.setVisible(false);
	System.exit(0);
    }
}









